<!DOCTYPE html>
<title>Test that a media element doesn't reload on removing the current source element and inserting a new source element.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<audio></audio>
<script>
async_test(function(t) {
    var audio = document.querySelector("audio");

    audio.oncanplaythrough = t.step_func_done(function() {
        assert_equals(audio.currentSrc, sourceA.src);
    });

    audio.onloadedmetadata = t.step_func(function() {
        audio.removeChild(sourceA);
        audio.appendChild(sourceB);
        audio.onloadedmetadata = t.unreached_func();
    });

    var sourceA = document.createElement("source");
    sourceA.src = "content/test.oga";
    var sourceB = document.createElement("source");
    sourceB.src = "content/silence.oga";
    audio.appendChild(sourceA);
});
</script>